<template>
  <t-image-viewer v-if="!store.isMobileType" v-model:visible="ImgVisible" :images="[urls + props.info.value]">
  </t-image-viewer>
  <van-image-preview :show-index="false" v-else v-model:show="ImgVisible" :images="[urls + props.info.value]">
  </van-image-preview>
  <div class="outline-parent">
    <img 
      class="outline-parent-bg"
      :src="publicUrls + 'free/style1/Auxiliaryoutlinestyle1Bg.webp'"
      alt=""
    />
    <div class="outline border-hover-style">
      <div class="outline-title">
        <div class="outline-title-content" v-html="textType(props.info.text)"></div>
      </div>
      <div class="outline-content">
        <p class="outline-subTitle" v-if="props.info.subTitle">——{{ props.info.subTitle }}</p>
        <div
          class="medium"
          v-if="props.info.value || (props.info.video && props.info.video.url)"
          :class="
            !props.info.remarks && !props.info.subTitle ? 'outline-re2' : !props.info.remarks ? 'outline-re1' : ''
          "
        >
          <img
            v-if="!(props.info.video && props.info.video.url)"
            class="outline-cover"
            @click="ImgVisible = true"
            :src="urls + props.info.value + '?imageView2/3/w/898/h/460/format/webp'"
            alt=""
          />
          <!-- <video
            v-if="props.info.video && props.info.video.url"
            class="outline-cover"
            :src="urls + props.info.video.url" 
            @click="videoplay"
          ></video> -->
          <videoview :info="props.info"></videoview>
        </div>
        <TextMax
          v-if="props.info && props.domShow"
          :data="props.info.remarks"
          :title="props.info.text"
          :row="props.info.value || (props.info.video && props.info.video.url) ? (props.info.subTitle ? 2 : 3) : 9"
        ></TextMax>
      </div>
      <div class="outline-right" v-if="props.info.audio && props.info.audio.url">
        <div class="right-content" :class="audioFlag && 'rotate'" @click="audioplay">
          <i class="doorIcon">&#xe688;</i>
        </div>
      </div>
      <audio v-if="props.info.audio && props.info.audio.url" :src="urls + props.info.audio.url" ref="audioRef"></audio>
    </div>
  </div>
</template>

<script lang="ts">
export default defineComponent({
  name: 'style1',
});
</script>

<script setup lang="ts">
import videoview from './../../../videoDialog/videoview.vue';
import { publicUrls, textType } from '@/utils/minxin';
import textMode from '../../../textMode/textMode.vue';
import { urls } from '@/utils/request/upload';
import { defineComponent, onMounted, ref, watch } from 'vue';
import TextMax from '@/freeComponents/textMode/TextMax.vue';
import { useProjectStore } from '@/store';

const ImgVisible = ref(false);
const visible = ref(false);
const store = useProjectStore();
const props = defineProps({
  info: {
    type: Object,
  },
  domShow: {
    type: Boolean,
  },
});

const audioRef = ref(null);
const audioFlag = ref(false);

const audioplay = () => {
  if (audioRef.value.paused) {
    audioRef.value.play();

    audioFlag.value = true;
  } else {
    audioRef.value.pause();
    audioFlag.value = false;
  }
};

watch(
  () => store.videoInfoShow,
  (val) => {
    if (val) {
      if (audioRef.value) {
        audioRef.value.pause();
        audioFlag.value = false;
      }
    }
  },
);
</script>

<style scoped lang="less">
.outline-parent {
  position: relative;
  -webkit-box-reflect: below 60% linear-gradient(transparent, rgba(0, 0, 0, 0.15));
}
.outline-parent-bg {
  width: 816px;
  height: 378px;
  margin-top: 78px;
  object-fit: cover;
}
.outline {
  position: absolute;
  top: 78px;
  left: 0;
  z-index: 20;
  display: flex;
  width: 816px;
  height: 378px;
  padding: 0px 33px;
  padding-top: 5px;
}
.outline-title {
  display: flex;
  align-items: center;
  width: 133px;
  height: 99%;
  border-right: 0.75px solid rgba(136, 120, 107, 0.3);
  .outline-title-content {
    display: flex;
    align-items: center;
    margin-left: 65px;
    flex: 1;
    height: 100%;
    ::v-deep p {
      writing-mode: vertical-rl; /* 从右到左的竖向排列 */
      text-align: center;
      font-family: SourceHanSerifCN-Bold;
      font-size: 20px;
      line-height: 28px;
      max-height: 224px;
      color: rgba(85, 59, 42, 1);
    }
  }
}
.outline-content {
  display: flex;
  flex-direction: column;
  margin-left: 44px;
  width: 510px;
  padding: 20px 0px;
  padding-bottom: 24px;
}
.outline-right {
  display: flex;
  align-items: center;
  width: 40px;
  height: 100%;
  margin-left: 25px;
  .right-content {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 1.6px solid rgba(85, 59, 42, 1);
    border-radius: 50%;
    .doorIcon {
      font-size: 20px;
      color: rgba(85, 59, 42, 1);
    }
  }
  .rotate {
    animation: rotate 4s linear infinite;
    @keyframes rotate {
      0% {
        transform: rotate(0deg);
      }
      100% {
        transform: rotate(360deg);
      }
    }
  }
}
.medium {
  width: 100%;
  height: 168px;
  border-radius: 84px;
  margin-bottom: 20px;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
  .outline-cover {
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: rgba(244, 205, 134, 0.2);
  }
}
.outline-re1 {
  height: 280px !important;
  border-radius: 146.5px !important;
  margin-bottom: 0 !important;
}
.outline-re2 {
  height: 100% !important;
  border-radius: 169px !important;
  box-shadow: 0px 0px 13.3px rgba(0, 0, 0, 0.25);
  margin-bottom: 0 !important;
}
.outline-subTitle {
  width: 100%;
  text-align: center;
  font-family: SourceMedium;
  font-size: 15px;
  line-height: 28px;
  text-align: center;
  margin-bottom: 17px;
  color: rgba(50, 43, 37, 1);
}

.outline-remarks {
  width: 100%;
  :deep(.openText) {
    color: rgba(85, 59, 42, 1);
    span {
      color: rgba(85, 59, 42, 1);
    }
  }
  :deep(.text p) {
    color: rgba(50, 43, 37, 1);
  }
  :deep(.omission) {
    color: rgba(50, 43, 37, 1);
  }
}
</style>
